package org.hu.utils;

import org.hu.mapper.DishMapper;
import org.hu.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component
public class MonthlyTask {

    @Autowired
    private DishMapper dishMapper;

    /**
     * 每月1号0点执行
     */
    @Scheduled(cron = "0 0 0 1 * ?")
//    @Scheduled(cron = "*/3 * * * * ?")  // 每三秒执行一次
    @Transactional
    public void resetDishCount() {
        dishMapper.resetCount();
        System.out.println("已在每月1号0点重置字段");
    }
}
